package com.my.study.alibaba;

import java.util.List;
import java.util.concurrent.locks.LockSupport;

/**
 * @author Carlos
 * @version 1.0.0
 * @date 2023/2/24 19:06
 */
public class Job {

    public void doJob(Works works) {
        LockSupport.park();

        List<Runnable> worksList = works.getWorks();
        // todo 执行任务
        System.out.println(works.getWorkId());
        
        LockSupport.unpark(works.getNext());
    }

    public static void main(String[] args) {

    }
}

/**
 * 任务封装
 */
class Works extends Thread{
    
    private List<Runnable> work;
    
    private Thread next;

    private String workId;
    
    public Works(List<Runnable> work, Thread next, String workId) {
        this.work = work;
        this.next = next;
        this.workId = workId;
    }
    
    public List<Runnable> getWorks() {
        return work;
    }

    public Thread getNext() {
        return next;
    }

    public String getWorkId() {
        return workId;
    }

    @Override
    public void run() {
        // todo 执行
    }
}